package com.ibangnuo.manage.controller.alipay;


import com.ibangnuo.api.alipay.PayControllerApi;
import com.ibangnuo.framework.domain.request.alipay.*;
import com.ibangnuo.framework.model.response.ObjectResult;
import com.ibangnuo.framework.model.response.ResponseResult;

import com.ibangnuo.manage.service.alipay.PayService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.Map;

/**
 * @Author: wwy
 * @Date: 2019-12-19 16:19
 */
@RestController
@RequestMapping("/api")
public class PayController implements PayControllerApi {
    @Autowired
    private PayService payService;
    /**
     * 支付接口
     * @param payRequest
     * @return
     */
    @PostMapping("/pay")
    @Override
    public ObjectResult pay(@RequestBody PayRequest payRequest) {
        return payService.pay(payRequest);
    }

    /**
     * 资金冻结
     * @param freezingFundRequest
     * @return
     */
    @PostMapping("/freeze")
    @Override
    public ResponseResult freeze(@RequestBody FreezingFundRequest freezingFundRequest) {
        return payService.freeze(freezingFundRequest);
    }

    /**
     * 退款接口
     * @param refundRequest
     * @return
     */
    @PostMapping("/refund")
    @Override
    public ResponseResult refund(@RequestBody RefundRequest refundRequest) {
        return payService.refund(refundRequest);
    }

    /**
     * 预创建订单id
     * @param preCreateRequest
     * @return
     */
    @PostMapping("/preCreate")
    @Override
    public ObjectResult preCreate(@RequestBody PreCreateRequest preCreateRequest) {
        return payService.preCreate(preCreateRequest);
    }

    /**
     * 查询订单状态
     * @param payQueryResultResquest
     * @return
     */
    @PostMapping("/queryResult")
    @Override
    public ObjectResult queryResult(@RequestBody PayQueryResultResquest payQueryResultResquest) {
        return payService.queryResult(payQueryResultResquest.getOutTradeNo(),payQueryResultResquest.getTradeNo());
    }

    /**
     * 用户是否扫码
     * @param payQueryResultResquest
     * @return
     */
    @PostMapping("/queryResultTwo")
    @Override
    public ObjectResult queryResultTwo(@RequestBody PayQueryResultResquest payQueryResultResquest) {
        return payService.queryResultTwo(payQueryResultResquest.getOutTradeNo(),payQueryResultResquest.getTradeNo());
    }


}
